const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: '/',
  outputDir: 'dist',
  assetsDir: 'static',
  indexPath: 'index.html',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    port: 10086,
    host: 'localhost',
    open: true,
    disableHostCheck: true,
    //proxy: 'http://dev.gozoom.cn:9001'
    //proxy: 'http://192.168.8.136:8099'
    proxy: 'http://192.168.18.117:9002'
    /*proxy: {
      '/yolo-star-manager': {
        target: 'http://192.168.8.136:8099/',
        // target: 'http://192.168.18.117:30000/',
        ws: true,
        changeOrigin: true
      },
      '/yolo-star-app-user': {
        target: 'http://192.168.8.196:8096/',
        // target: 'http://192.168.18.117:30000/',
        ws: true,
        changeOrigin: true
      },
      '/yolo-insurance-server': {
        // target: 'http://localhost:13333',
        target: 'http://dev.gozoom.cn:29001',
        ws: true,
        changeOrigin: true
      },
      '/fileserver': {
        // target: 'http://localhost:60000',
        target: 'http://dev.gozoom.cn:29001',
        changeOrigin: true,
        pathRewrite: {
          // '^/st-sell-server': '/st-sell-server',
          '^/fileserver': '/fileserver'
        }
      }
    }*/
  },
  configureWebpack: {
    optimization: {
      minimizer: [
        new UglifyJsPlugin({
          uglifyOptions: {
            compress: {
              drop_console: true,
              drop_debugger: false,
              pure_funcs: ['console.log']
            }
          }
        })
      ]
    },
    resolve: {
      alias: {
        vue$: 'vue/dist/vue.esm.js',
        '@': resolve('src'),
        '@style': resolve('src/assets/style'),
        '@libs': resolve('src/libs'),
        '@views': resolve('src/views')
      }
    }
  },
  css: {
    // 配置css模块
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  chainWebpack: config => {
    config.module
      .rule('vue')
      .use('iview-loader')
      .loader('iview-loader')
      .options({
        prefix: false
      });
  },
  pwa: {
    iconPaths: {
      favicon32: 'favicon.ico',
      favicon16: 'favicon.ico',
      appleTouchIcon: 'favicon.ico',
      maskIcon: 'favicon.ico',
      msTileImage: 'favicon.ico'
    }
  }
};
